package com.sunda.spmswms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sunda.spmswms.entity.WhsDumpDtl;
import com.sunda.spmswms.mapper.WhsDumpDtlMapper;
import com.sunda.spmswms.service.IWhsDumpDtlService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 转储任务明细表 服务实现类
 * </p>
 *
 * @author Wayne
 * @since 2021-06-29
 */
@Service
public class WhsDumpDtlServiceImpl extends ServiceImpl<WhsDumpDtlMapper, WhsDumpDtl> implements IWhsDumpDtlService {

    @Override
    public List<Map<String, Object>> getWhsDumpDtlList(String whsDumpUuid) {
        if (StringUtils.isEmpty(whsDumpUuid)){
            return null;
        }
        return this.baseMapper.getWhsDumpDtlList(whsDumpUuid);
    }

    @Override
    public int createWhsDumpDtl(WhsDumpDtl whsDumpDtl) {
        if (StringUtils.isEmpty(whsDumpDtl.toString())){
            return 0;
        }
        return this.baseMapper.insert(whsDumpDtl);
    }

    @Override
    public int deleteWhsDumpDtl(String whsDumpUuid) {
        if (StringUtils.isEmpty(whsDumpUuid)){
            return 0;
        }
        return this.baseMapper.delete(new QueryWrapper<WhsDumpDtl>().eq("WHS_DUMP_UUID", whsDumpUuid));
    }

    @Override
    public List<WhsDumpDtl> getWhsDumpDtlListByUuid(String whsDumpUuid) {
        if (StringUtils.isEmpty(whsDumpUuid)){
            return null;
        }
        return this.baseMapper.selectList(new QueryWrapper<WhsDumpDtl>()
                .eq("WHS_DUMP_UUID", whsDumpUuid).gt("ACTUAL_OUT_QTY", 0));
    }
}
